home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Programming Contest / Secret Solutions Folder / Problem 06 - Legal Chess Moves / Solution.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-06  |  1004 b   |  47 lines  |  [TEXT/CWIE]

  1. #ifndef __SOLUTION_H__
  2. #define __SOLUTION_H__
  3.  
  4. // Do not modify this file
  5.  
  6. #include <MacTypes.h>
  7. #include <Files.h>
  8.  
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif // __cplusplus
  12.  
  13. typedef enum {kEmpty=0,kWhite,kBlack} PieceColor;
  14. typedef enum {kNone=0,kPawn,kKnight,kBishop,kRook,kQueen,kKing} PieceRank;
  15.  
  16. typedef struct Square {
  17.     UInt16 row;    /* 0..7, white initially occupies rows 0 and 1, black 7 and 6 */
  18.     UInt16 col;    /* 0..7, white king starts at (row,col) == (0,4) */
  19. } Square;
  20.  
  21. typedef struct ChessMove {
  22.     Square fromSquare;
  23.     Square toSquare;
  24.     Boolean capture;
  25.     Square capturedSquare;    /* valid only if capture==TRUE */
  26. } ChessMove;
  27.  
  28. typedef struct ChessPiece {
  29.     PieceColor whichColor;
  30.     PieceRank whichRank;
  31.     Square pieceLocation;
  32. } ChessPiece;
  33.  
  34. pascal void FindLegalChessMoves(
  35.     UInt32 numPriorMoves,
  36.     ChessMove priorMoves[],
  37.     UInt32 *numPiecesRemaining,
  38.     ChessPiece piecesRemaining[],
  39.     UInt32 *numLegalMoves,
  40.     ChessMove legalMoves[]
  41. );
  42.  
  43. #ifdef __cplusplus
  44. }
  45. #endif // __cplusplus
  46.  
  47. #endif // __SOLUTION_H__